Skip to content

Enhance required_restart.py to use native commands#242

Merged
bkbilly merged 6 commits into
bkbilly:masterfrom
jeremysherriff:patch-2
May 3, 2026
Merged

Enhance required_restart.py to use native commands#242
bkbilly merged 6 commits into
bkbilly:masterfrom
jeremysherriff:patch-2

Conversation

@jeremysherriff

Copy link
Copy Markdown
Contributor

Addresses #239 by detecting available commands, falling back to original behaviour if required. Aligns with sys_updates.py for 6-minute check interval.

Addresses bkbilly#239 by detecting available commands, falling back to original behaviour if required. Aligns with sys_updates.py for 6-minute check interval.
@bkbilly

bkbilly commented May 3, 2026

Copy link
Copy Markdown
Owner

I appreciate you took the time to create this PR.
I've tried it on Ubuntu and it works great!

@bkbilly bkbilly merged commit 93b12f2 into bkbilly:master May 3, 2026
2 checks passed
@jeremysherriff

Copy link
Copy Markdown
Contributor Author

FYI below. I do not consider this needs documenting; if the admin has pinned the kernel version as described below then presumably they are an advanced user and can react accordingly.


An edge-case downside of this approach is present when kernel versions are managed externally and the administrator chooses to pin an older version, such as with Proxmox;

jeremy@pve:~$ sudo uname -r
6.17.13-7-pve

jeremy@pve:~$ sudo proxmox-boot-tool kernel list
Manually selected kernels:
None.

Automatically selected kernels:
6.17.13-7-pve
7.0.2-2-pve

Pinned kernel:
6.17.13-7-pve

jeremy@pve:~$ sudo needrestart -p
CRIT - Kernel: 6.17.13-7-pve!=7.0.2-2-pve (!!), Microcode: CURRENT, Services: none, Containers: none, Sessions: none|Kernel=2;0;;0;2 Microcode=0;0;;0;1 Services=0;;0;0 Containers=0;;0;0 Sessions=0;0;;0

It is recommended to always manually inspect the details: attribute of the Required Restart sensor to determine the cause of the Positive result, and react based on content.

To direct needrestart to ignore your pinned kernel version, create a drop-in file in /etc/needrestart/conf.d/ with the directive $nrcon{kernelfilter}:

root@pve:~# cat /etc/needrestart/conf.d/10-kernel-pin.conf
$nrconf{kernelfilter} = qr(vmlinuz-6\.17\.13-7-pve);

Note the use of regex, so . characters must be escaped. The filter is inclusive so will not alert to the exact specified value, but will alert to anything else. Adjust the content of this file each time you change the pinned version, and delete the file when you remove the kernel pin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants